Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

End-to-end tests for the complete user workflow: objectdocs init → content creation → objectdocs buildobjectdocs migrate.

Tests (packages/cli/test/cli-lifecycle.test.mjs)

6 sequential tests in a shared temp directory mirroring real usage:

  • CLI help — binary loads, all commands listed
  • objectdocs init.fumadocs/ scaffolded, content/package.json with scripts, .gitignore updated, deps installed
  • Idempotent init — second run detects existing installation
  • Content creation — MDX files, meta.json, docs.site.json written and validated
  • objectdocs build — Next.js production build produces .next output
  • objectdocs migrate.md.mdx with frontmatter extraction, H1 removal, body preservation, meta.json update

Bug fix (packages/site/next.config.mjs)

The init workflow was broken: Turbopack (Next.js 16) cannot resolve imports outside the project root. Content lives at ../../docs/ relative to .fumadocs/.source/, which is outside .fumadocs/.

outputFileTracingRoot: path.resolve(__dirname, '../..'),

This extends Turbopack's resolution scope to include the content directory. Monorepo build is unaffected.

Infrastructure

  • Added vitest to packages/cli devDependencies
  • vitest.config.mjs with 600s timeout for integration tests
  • Updated test script from echo "No test"vitest run

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectdocs Ready Ready Preview, Comment Feb 9, 2026 7:08am

Request Review

Copilot AI and others added 2 commits February 9, 2026 06:44
- Add vitest as dev dependency to packages/cli
- Create comprehensive integration test verifying full CLI lifecycle:
  init → content creation → build
- Fix outputFileTracingRoot in next.config.mjs to allow Turbopack
  to resolve content files outside the .fumadocs project root
- Update packages/cli test script from placeholder to vitest run

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🚀 Preview Deployment

This pull request will be automatically deployed to Vercel.

Preview Links

  • 📝 Documentation: Will be available once Vercel deployment completes
  • 🌍 Languages: English (/en/docs) and Chinese (/cn/docs)

Build Status

Check the CI workflow for build status and any errors.


Automated preview information for PR #50

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for CLI command project initialization Add CLI lifecycle integration tests with vitest Feb 9, 2026
Copilot AI requested a review from hotlong February 9, 2026 06:50
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🚀 Preview Deployment

This pull request will be automatically deployed to Vercel.

Preview Links

  • 📝 Documentation: Will be available once Vercel deployment completes
  • 🌍 Languages: English (/en/docs) and Chinese (/cn/docs)

Build Status

Check the CI workflow for build status and any errors.


Automated preview information for PR #50

@hotlong hotlong marked this pull request as ready for review February 9, 2026 07:27
Copilot AI review requested due to automatic review settings February 9, 2026 07:27
@hotlong hotlong merged commit 357a2f9 into main Feb 9, 2026
11 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end CLI lifecycle integration coverage (init → content → build → migrate) using Vitest, and updates the site’s Next.js config to fix Turbopack file tracing for content outside the project root.

Changes:

  • Add Vitest-based CLI lifecycle integration test suite covering init/build/migrate.
  • Add Vitest configuration + wire up pnpm test for packages/cli.
  • Update packages/site/next.config.mjs with outputFileTracingRoot to fix init/build workflows under Next.js/Turbopack.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds vitest (and transitive toolchain) to the workspace lockfile.
packages/site/next.config.mjs Sets outputFileTracingRoot for broader file tracing scope.
packages/cli/vitest.config.mjs Adds long timeouts suitable for end-to-end integration tests.
packages/cli/test/cli-lifecycle.test.mjs New sequential lifecycle integration tests executing real CLI commands.
packages/cli/package.json Switches test to vitest run and adds vitest devDependency.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

const __dirname = path.dirname(__filename);

const CLI_PATH = path.resolve(__dirname, '../bin/cli.mjs');
const MONOREPO_ROOT = path.resolve(__dirname, '../../..');
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MONOREPO_ROOT is declared but never used. Please remove it to avoid confusion about whether the tests depend on monorepo paths.

Suggested change
const MONOREPO_ROOT = path.resolve(__dirname, '../../..');

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +38
function runCli(args, options = {}) {
const { cwd = testDir, env: extraEnv = {}, timeout = 300_000 } = options;
return execFileSync(process.execPath, [CLI_PATH, ...args], {
cwd,
timeout,
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runCli defaults to a 5-minute execFileSync timeout, but the vitest config allows 10 minutes. Long npm install / next build runs could be killed by the shorter process timeout even though the test timeout hasn’t elapsed. Consider bumping the default to match the vitest timeout (or threading it through from config).

Copilot uses AI. Check for mistakes.
});
}

describe('CLI Lifecycle: init → content → build', () => {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests rely on shared state across multiple it(...) blocks. To prevent future flakiness if vitest is configured to run tests concurrently, make the suite explicitly sequential (e.g., describe.sequential(...) or equivalent vitest sequencing config).

Suggested change
describe('CLI Lifecycle: init → content → build', () => {
describe.sequential('CLI Lifecycle: init → content → build', () => {

Copilot uses AI. Check for mistakes.
Comment on lines +31 to 33
"devDependencies": {
"vitest": "^4.0.18"
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding vitest (which requires Node >=20 per the lockfile) changes the effective Node baseline for this workspace/package, but package.json doesn’t declare an engines.node range. Consider adding engines (and aligning CI/release, which currently uses Node 18) or pinning to a Vitest version compatible with the supported Node version.

Copilot uses AI. Check for mistakes.
Comment on lines +2710 to +2713
vite@7.3.1:
resolution: {integrity: sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vite@7.3.1 declares a strict Node engine requirement (^20.19.0 || >=22.12.0). Since this is now in the lockfile, installs on Node 18 will fail and even “Node 20” environments must be new enough. Align supported Node versions/CI (or pin to a toolchain that supports the intended Node baseline).

Copilot uses AI. Check for mistakes.
Comment on lines +2750 to +2753
vitest@4.0.18:
resolution: {integrity: sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==}
engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
hasBin: true
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitest@4.0.18 requires Node ^20.0.0 || ^22.0.0 || >=24.0.0. Please ensure the repo’s documented/CI Node version matches this (the release workflow currently uses Node 18), or pin Vitest to a version that supports the older runtime.

Copilot uses AI. Check for mistakes.
*/

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { execSync, execFileSync } from 'child_process';
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execSync is imported but never used in this test file. Removing unused imports keeps the integration test easier to maintain and avoids lint/tooling warnings if added later.

Suggested change
import { execSync, execFileSync } from 'child_process';
import { execFileSync } from 'child_process';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants